<?php
session_start();
require_once('check_login.php');
include(dirname(__FILE__) . '/config.php');
require_once('contacts_lib.php');
$contacts=get_all_contacts();
require_once('header.php');
?>

<!-- BEGIN CONTAINER -->
<div class="page-container">
	<!-- BEGIN SIDEBAR -->
	<?php require_once('left_menu.php'); ?>
	<!-- END SIDEBAR -->
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			
			<!-- /.modal -->
			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
			<!-- BEGIN STYLE CUSTOMIZER -->
			
			<!-- END STYLE CUSTOMIZER -->
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					
					<ul class="page-breadcrumb breadcrumb">
						
						<li>
							<i class="fa fa-home"></i>
							<a href="dashboard.php">
								Trang chủ
							</a>
							<i class="fa fa-angle-right"></i>
						</li>
						<li>
							<a href="contacts.php">
								Danh sách đối tác
							</a>
							<i class="fa fa-angle-right"></i>
						</li>
						
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="">
						
						<div class="portlet-body">
							<div class="table-toolbar">
								<div class="btn-group">
									<button id="contacts_table_new" class="btn green">
									Thêm mới <i class="fa fa-plus"></i>
									</button>
								</div>
								<div class="btn-group pull-right">
									<button class="btn dropdown-toggle" data-toggle="dropdown">Thao tác <i class="fa fa-angle-down"></i>
									</button>
									<ul class="dropdown-menu pull-right">
										<li>
											<a href="#">
												 Đọc từ file Excel
											</a>
										</li>
										
									</ul>
								</div>
							</div>
							<table class="table table-striped table-hover table-bordered" id="contacts_table">
							<thead>
							<tr>
								<th>
									 Mã
								</th>
								<th>
									 Họ
								</th>
								<th>
									 Tên
								</th>
								<th>
									 Email
								</th>
								<th>
									 Số điện thoại
								</th>
								<th>
									 Sửa
								</th>
								<th>
									 Xóa
								</th>
								<th>
									 Sửa chi tiết
								</th>
							</tr>
							</thead>
							<tbody>
							
							<?php foreach($contacts as $contact){ ?>
							<tr>
								<td>
									 <?php echo $contact['id'] ?>
								</td>
								<td>
									 <?php echo $contact['first_name'] ?>
								</td>
								<td>
									 <?php echo $contact['last_name'] ?>
								</td>
								<td>
									 <?php echo $contact['email'] ?>
								</td>
								<td class="center">
									 <?php echo $contact['phone'] ?>
								</td>
								<td>
									<a class="edit" href="javascript:;">
										 Sửa
									</a>
								</td>
								<td>
									<a class="delete" href="javascript:;">
										 Xóa
									</a>
								</td>
								<td>
									<a href="edit_contact_detail.php?id=<?php echo $contact['id'] ?>">
										 Sửa chi tiết
									</a>
								</td>
							</tr>
							<?php } ?>
							
							
							</tbody>
							</table>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</div>
			<!-- END PAGE CONTENT -->
		</div>
	</div>
	<!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
<?php 
require_once('footer.php');
require_once('common_script.php');
?>

<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="assets/scripts/core/app.js"></script>
<script src="js/contacts.js"></script>
<script>
jQuery(document).ready(function() {       
   App.init();
   TableEditable.init();
});
</script>
</body>
<!-- END BODY -->
</html>